-module(bnode_inverter).
-include("btree.hrl").

%% API
-export([forward/2]).
-export([backward/2]).

forward(BTree, BNode) ->
    #bn{children = [Children]} = BNode,
    bnode_api:forward(BTree, Children).

backward(#bt{result = Res} = BTree, BNode) ->
    NewRes =
        case Res of
            ?SUCCESS -> ?FAILURE;
            ?FAILURE -> ?SUCCESS
        end,
    bnode_api:backward(BTree#bt{result = NewRes}, BNode).
